home *** CD-ROM | disk | FTP | other *** search
/ Borland JBuilder 6 / jbuilder6.iso / Taiji Applet Pack v2.7 / PasswordedDownload / LoginFrame.class (.txt) next >
Encoding:
Java Class File  |  2001-11-06  |  3.4 KB  |  98 lines

  1. import java.awt.Button;
  2. import java.awt.Frame;
  3. import java.awt.Window;
  4. import java.awt.event.ActionEvent;
  5. import java.awt.event.ActionListener;
  6. import java.awt.event.WindowEvent;
  7. import java.awt.event.WindowListener;
  8. import java.net.URL;
  9. import java.util.EventObject;
  10.  
  11. class LoginFrame extends Frame implements WindowListener, ActionListener {
  12.    // $FF: renamed from: lb PasswordedDownload
  13.    PasswordedDownload field_0;
  14.  
  15.    LoginFrame(String title, PasswordedDownload lb) {
  16.       super(title);
  17.       this.field_0 = lb;
  18.       ((Window)this).addWindowListener(this);
  19.    }
  20.  
  21.    public void windowClosing(WindowEvent e) {
  22.       ((Frame)this).dispose();
  23.    }
  24.  
  25.    public void windowClosed(WindowEvent e) {
  26.    }
  27.  
  28.    public void windowOpened(WindowEvent e) {
  29.    }
  30.  
  31.    public void windowIconified(WindowEvent e) {
  32.    }
  33.  
  34.    public void windowDeiconified(WindowEvent e) {
  35.    }
  36.  
  37.    public void windowActivated(WindowEvent e) {
  38.    }
  39.  
  40.    public void windowDeactivated(WindowEvent e) {
  41.    }
  42.  
  43.    public String decode(String codeBase) {
  44.       char[] chars = new char[codeBase.length()];
  45.       codeBase.getChars(0, codeBase.length(), chars, 0);
  46.       String key = new String("haricots");
  47.       char[] chars2 = new char[key.length()];
  48.       key.getChars(0, key.length(), chars2, 0);
  49.       int k = 0;
  50.  
  51.       for(int i = 0; i < codeBase.length(); ++i) {
  52.          ++k;
  53.          if (k == 4) {
  54.             k = 1;
  55.          }
  56.  
  57.          if (i >= key.length()) {
  58.             int var10000 = i - key.length() * (i / key.length());
  59.          }
  60.  
  61.          chars[i] = (char)(chars[i] - k);
  62.       }
  63.  
  64.       String res = new String(chars);
  65.       return res;
  66.    }
  67.  
  68.    public void actionPerformed(ActionEvent evt) {
  69.       Button b = (Button)((EventObject)evt).getSource();
  70.       if (b.getLabel().equals("Cancel")) {
  71.          ((Frame)this).dispose();
  72.          this.field_0.stop();
  73.       } else {
  74.          if (b.getLabel().equals("Ok")) {
  75.             String pass = this.field_0.t2.getText();
  76.             String passvrai = this.field_0.getParameter("password");
  77.             System.out.println(this.decode(passvrai));
  78.             if (this.decode(passvrai).equals(pass)) {
  79.                URL u = this.field_0.giveURL(this.decode(this.field_0.getParameter("link")));
  80.                ((Frame)this).dispose();
  81.                String target = this.field_0.getParameter("target");
  82.                if (target == null) {
  83.                   target = "_blank";
  84.                }
  85.  
  86.                this.field_0.getAppletContext().showDocument(u, target);
  87.                this.field_0.stop();
  88.                return;
  89.             }
  90.  
  91.             ((Frame)this).setTitle(this.field_0.title + ": wrong password !");
  92.             this.field_0.t2.setText("");
  93.          }
  94.  
  95.       }
  96.    }
  97. }
  98.